package com.slashmobility.finapps.model;

import com.slashmobility.finappsparty.helper.DateHelper;

/**
 * Clase que modela una orden de compra/venta
 * @author josecortes
 */

public class DataModelOrden {
	private String account;
	private String avgPrice;
	private String date;
	private String marquetPc;
	private String orderSide;
	private String orderType;	
	private String pc;
	private String price;
	private String quote;
	private String ref;
	private String status;
	private String triggerPrice;
	private String validDate;
	private String vol;
	private String timeRestriction;

	
	private static final String usuario="PEPITO";
	
	public static final String ORDEN_STATE_PENDIENTEDISPARO="-1";
	public static final String ORDEN_STATE_CANCELADA="1";
	public static final String ORDEN_STATE_EJECUCIONPARCIAL="2";
	public static final String ORDEN_STATE_EJECUCION="3";
	public static final String ORDEN_STATE_EJECUCIONPARCIALCANCELADA="4";
	public static final String ORDEN_STATE_ENMERCADO="5";
	public static final String ORDEN_STATE_RECIBIDA="6";
	public static final String ORDEN_STATE_CONFIRMADASERVIDOR="7";
	public static final String ORDEN_STATE_CONFIRMADAMERCADO="8";
	public static final String ORDEN_STATE_PENDIENTEMERCADO="9";
	public static final String ORDEN_STATE_PENDIENTESTOP="10";
	

	public static final int ORDEN_TIPO_LIMITADA = 0;
	public static final int ORDEN_TIPO_STOP_LIMITADA = 3;
	public static final int ORDEN_TIPO_A_MERCADO = 5;
	public static final int ORDEN_TIPO_STOP_A_MERCADO = 6;
	
	public static final String ORDEN_SIDE_COMPRA="Compra";
	public static final String ORDEN_SIDE_VENTA="Venta";
	
	public static final int ORDEN_SIDE_ID_COMPRA=0;
	public static final int ORDEN_SIDE_ID_VENTA=1;
	
 
	
	
	public String getAvgPrice() {
		return avgPrice;
	}
	public String getTimeRestriction() {
		return timeRestriction;
	}
	public void setTimeRestriction(String timeRestriction) {
		this.timeRestriction = timeRestriction;
	}
	public void setAvgPrice(String avgPrice) {
		this.avgPrice = avgPrice;
	}
	public String getDate() {
		return date;
	}
	public void setDate(String date) {
		this.date = date;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getAccount() {
		return account;
	}
	public void setAccount(String account) {
		this.account = account;
	}
	public String getMarquetPc() {
		return marquetPc;
	}
	public void setMarquetPc(String marquetPc) {
		this.marquetPc = marquetPc;
	}
	public String getOrderSide() {
		return orderSide;
	}
	public void setOrderSide(String orderSide) {
		this.orderSide = orderSide;
	}
	public String getOrderType() {
		return orderType;
	}
	public void setOrderType(String orderType) {
		this.orderType = orderType;
	}
	public String getPc() {
		return pc;
	}
	public void setPc(String pc) {
		this.pc = pc;
	}
	public String getPrice() {
		return price;
	}
	public void setPrice(String price) {
		this.price = price;
	}
	public String getQuote() {
		return quote.replaceAll(" ", "%20");
	}
	public void setQuote(String quote) {
		this.quote = quote;
	}
	public String getRef() {
		return ref;
	}
	public void setRef(String ref) {
		this.ref = ref;
	}
	//public String getServicio() {
	//	return servicio;
	//}
	//public void setServicio(String servicio) {
	//	this.servicio = servicio;
	//}
	public String getTriggerPrice() {
		return triggerPrice;
	}
	public void setTriggerPrice(String triggerPrice) {
		this.triggerPrice = triggerPrice;
	}
	//public String getUser() {
	//	return user;
	//}
	//public void setUser(String user) {
	//	this.user = user;
	//}
	public String getValidDate() {
		return validDate;
	}
	public void setValidDate(String validDate) {
		this.validDate = validDate;
	}
	public String getVol() {
		return vol;
	}
	public void setVol(String vol) {
		this.vol = vol;
	}
	
	public String toXMLAlta()
	{
		String marquetPcStr=this.marquetPc==null?"":this.marquetPc;
		String accountStr=this.account==null?"":this.account;
		String quoteStr=this.quote==null?"":this.quote;
		String orderTypeStr=this.orderType==null?"":this.orderType;
		String orderSideStr=this.orderSide==null?"":this.orderSide;
		String priceStr=this.price==null?"":this.price;
		String volStr=this.vol==null?"":this.vol;
		String triggerPriceStr=this.triggerPrice==null?"":this.triggerPrice;
		String pcStr=this.pc==null?"":this.pc;
		String refStr=this.ref==null?"":this.ref;
		String validDateStr=this.validDate==null?"":this.validDate;
		String timeRestrictionStr=this.timeRestriction==null?"":this.timeRestriction;
		
		String xml=
		"<orden>" +
		"<marquetPc>"+marquetPcStr+"</marquetPc>" +
		"<price>"+priceStr+"</price>" +
		"<quote>"+quoteStr+"</quote>" +
		"<servicio>WEBGVC</servicio>" +
		"<triggerPrice>"+triggerPriceStr+"</triggerPrice>" +
		"<user>"+usuario+ "</user>" +
		"<orderSide>"+orderSideStr+"</orderSide>" +		
		"<orderType>"+orderTypeStr+"</orderType>" +
		"<account>"+accountStr+"</account>" +
		"<validDate>"+validDateStr+"</validDate>"  +
		"<vol>"+volStr+"</vol>" +
		"<pc>"+pcStr+"</pc>" +
		"<ref>"+refStr+"</ref>" +			
		"<timeRestriction>"+timeRestrictionStr+"</timeRestriction>"  +
	"</orden>";
		
		return xml;
	}
	
	public String toXMLModificar()
	{
		String marquetPcStr=this.marquetPc==null?"":this.marquetPc;
		String accountStr=this.account==null?"":this.account;
		String quoteStr=this.quote==null?"":this.quote;
		String orderTypeStr=this.orderType==null?"":this.orderType;
		String orderSideStr=this.orderSide==null?"":this.orderSide;
		String priceStr=this.price==null?"":this.price;
		String volStr=this.vol==null?"":this.vol;
		String triggerPriceStr=this.triggerPrice==null?"":this.triggerPrice;
		String pcStr=this.pc==null?"":this.pc;
		String refStr=this.ref==null?"":this.ref;
		String validDateStr=this.validDate==null?"":this.validDate;
		String timeRestrictionStr=this.timeRestriction==null?"":this.timeRestriction;
		
		String xml=
		"<orden>" +
		"<servicio>WEBGVC</servicio>" +
		"<user>"+usuario+ "</user>" +
		"<marquetPc>"+marquetPcStr+"</marquetPc>" +
		"<account>"+accountStr+"</account>" +
		"<pc>"+pcStr+"</pc>" +
		"<price>"+priceStr+"</price>" +
		"<quote>"+quoteStr+"</quote>" +
		"<ref>"+refStr+"</ref>" +	
		"<triggerPrice>"+triggerPriceStr+"</triggerPrice>" +
		"<orderSide>"+orderSideStr+"</orderSide>" +		
		"<orderType>"+orderTypeStr+"</orderType>" +
		"<validDate>"+validDateStr+"</validDate>"  +
		"<vol>"+volStr+"</vol>" +
		"<timeRestriction>"+timeRestrictionStr+"</timeRestriction>"  +
	"</orden>";
		
		return xml;
	}
	
	public String toXMLCancelar()
	{
		String accountStr=this.account==null?"":this.account;
		String quoteStr=this.quote==null?"":this.quote;
		String priceStr=this.price==null?"":this.price;
		String volStr=this.vol==null?"":this.vol;
		String triggerPriceStr=this.triggerPrice==null?"":this.triggerPrice;
		String pcStr=this.pc==null?"":this.pc;
		String refStr=this.ref==null?"":this.ref;
		String validDateStr=this.validDate==null?"":this.validDate;
		String timeRestrictionStr=this.timeRestriction==null?"":this.timeRestriction;
		
		String xml=
		"<orden>" +
		"<user>"+usuario+ "</user>" +
		"<account>"+accountStr+"</account>" +
		"<quote>"+quoteStr+"</quote>" +
		"<pc>"+pcStr+"</pc>" +
		"<ref>"+refStr+"</ref>" +	
		"<vol>"+volStr+"</vol>" +
		"<price>"+priceStr+"</price>" +
		"<triggerPrice>"+triggerPriceStr+"</triggerPrice>" +
		"<validDate>"+DateHelper.getFormatedDateFrom(validDateStr).replaceAll("/", "_")+"</validDate>"  +
		"<servicio>WEBGVC</servicio>" +
		"<timeRestriction>"+timeRestrictionStr+"</timeRestriction>"+
		/*"<marquetPc>"+marquetPcStr+"</marquetPc>" +
		"<orderSide>"+orderSideStr+"</orderSide>" +		
		"<orderType>"+orderTypeStr+"</orderType>" +
		 */
	"</orden>";
		
		return xml;
	}
	  
}

